﻿Imports System.Data.SqlClient
Imports PhDir.DAL
Imports PhDir.Model
Imports PhDir.Repository
Imports System.Collections.Generic

Namespace Repository.User
    Public Class InsertUser
        Implements IInsert(Of Model.Phone)

        Public Function Insert(phone As Model.Phone) As Boolean _
            Implements IInsert(Of Model.Phone).Insert

            Dim isSuccess = False

            Using dbConnection = New DbConnection(DbContext.PhoneContext)
                dbConnection.AddParameter("@Name", phone.User.UserName)
                dbConnection.AddParameter("@Department", phone.User.Department.DepartmentName)
                dbConnection.AddParameter("@PlainPhoneNumber", phone.PhoneNumber)
                dbConnection.CommandText = StoredProceduresName.InsertUser
                dbConnection.CommandType = CommandType.StoredProcedure
                isSuccess = dbConnection.ExecuteNonQuery()
            End Using

            Return isSuccess

        End Function
    End Class
End Namespace
